package com.ruoyi.bigScreen.controller;

import com.ruoyi.bigScreen.domain.vo.BigScreenMeteringSupervisionVO;
import com.ruoyi.bigScreen.domain.vo.BigScreenWaterRegimeMonitoringVO;
import com.ruoyi.bigScreen.service.IBigScreenStStationBService;
import com.ruoyi.bigScreen.service.IBigScreenWaterRegimeMonitoringService;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.business.BusinessUtils;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 查询测站计量体系监管
 *
 * @author hwd
 * @date 2023-02-16
 */
@RestController
@RequestMapping("/BigScreenMeteringSupervision")
public class BigScreenMeteringSupervisionController extends BaseController
{
    @Autowired
    private IBigScreenStStationBService bigScreenStStationBService;

    @Autowired
    private IBigScreenWaterRegimeMonitoringService waterRegimeMonitoringService;

    /**
     * 查询测站计量体系监管
     */
    @GetMapping("/statTypeByRatio")
    public AjaxResult statTypeByRatio()
    {
        List<BigScreenMeteringSupervisionVO> voList = bigScreenStStationBService.statTypeByRatio();
        return AjaxResult.success(voList);
    }

    /**
     * 查询监测实时数据记录列表
     */
    @GetMapping("/listCountWaterStation")
    public AjaxResult listCountWaterStation()
    {

        List<BigScreenWaterRegimeMonitoringVO> countRegimeList = waterRegimeMonitoringService.selWaterRegimeMonitoringList();
        Map<String,Object> map=new HashMap<String,Object>();
        map.put("reportRegimeNum",countRegimeList.stream().filter(vo -> "0".equals(vo.getRunningState())).count());//在线
        map.put("faulRegimeNum",countRegimeList.stream().filter(vo ->! "0".equals( vo.getRunningState())).count());//离线
        List<BigScreenWaterRegimeMonitoringVO> countYieldList = waterRegimeMonitoringService.selWaterYieldRegimeMonitoringList();
        map.put("reportYieldNum",countYieldList.stream().filter(vo -> "0".equals(vo.getRunningState())).count());//在线
        map.put("faultYieldNum",countYieldList.stream().filter(vo ->! "0".equals( vo.getRunningState())).count());//离线
        List<BigScreenWaterRegimeMonitoringVO> countImageList = waterRegimeMonitoringService.selImageRegimeMonitoringList();
        map.put("reportImageNum",countImageList.stream().filter(vo -> "0".equals(vo.getRunningState())).count());//在线
        map.put("faultImageNum",countImageList.stream().filter(vo ->! "0".equals( vo.getRunningState())).count());//离线
        return AjaxResult.success(map);
    }

}
